/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package auborncorpcardealer;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author TQNINH
 */
public class GenericCar<T> {
    protected List<T> prodContents;
    
    public GenericCar() {
        prodContents = new ArrayList<T>();
        //prodContents = new ArrayList<>();
        //Generic JDK 1.7 
        //"Automatic Type Inference during the Generic Instance Creation"
    }
    
    public void add(T obj) {
        prodContents.add(obj);
    }
    
    public void display() {
        for(T cObj : prodContents) {
            System.out.println(cObj.toString()); 
        }
    }
    
    public int getSize() {
        return prodContents.size();
    }
    
    public boolean checkEmpty() {
        return (prodContents.size() == 0);
        //return prodContents.isEmpty();
    }
    
    public T grab() {
        if(!checkEmpty()) {
            return prodContents.remove(0);
        } else {
            return null;
        }
    }
}
